package com.yanqu.road.logic.activity.foxcard.game.spell;

import com.yanqu.road.entity.activity.foxcard.FoxBaseCard;
import com.yanqu.road.entity.activity.foxcard.FoxHandCard;
import com.yanqu.road.logic.activity.foxcard.FoxCardConfig;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardGameLogic;
import com.yanqu.road.logic.activity.foxcard.game.FoxCardShowInfo;
import com.yanqu.road.logic.activity.foxcard.game.eFoxCardShowType;

import java.util.ArrayList;
import java.util.List;

/**
 * 选定牌改花色
 * 数量|花色
 */
public class FoxCardSpellUse3 extends FoxCardSpellUseBase {
    @Override
    protected boolean spellUse(FoxCardGameLogic gameLogic) {
        int num = spellConfig.getParamList().get(0);
        int targetNum = targetIdList.size();
        if (targetNum <= 0 || targetNum > num) {
            return false;
        }
        FoxCardConfig config = gameLogic.getConfig();

        int changeColor = spellConfig.getParamList().get(1);
        List<FoxBaseCard> triggerCards = new ArrayList<>();
        for (Integer handCardId : targetIdList) {
            FoxHandCard foxHandCard = gameLogic.getGameData().getHandCards().stream().filter(handCard -> handCard.getId() == handCardId).findFirst().orElse(null);
            if (foxHandCard == null) {
                return false;
            }
//            if (config.isAllColorHandCard(foxHandCard.getReinforceEffect())) {
//                return false;
//            }
//            if (config.isNotPointAndNotColorHandCard(foxHandCard.getReinforceEffect())) {
//                return false;
//            }
            foxHandCard.setColor(changeColor);
            triggerCards.add(foxHandCard);
        }

        if (triggerCards.isEmpty()) {
            return false;
        }

        FoxCardShowInfo showInfo = gameLogic.newFoxShow(eFoxCardShowType.COLOR_CHANGE.getValue());
        showInfo.setTriggerCards(triggerCards);
        showInfo.setShowValue(changeColor);

        return true;
    }
}
